<template>
  <div>
    <Header/>
    <router-view></router-view>
    <!-- 第一种.meta传递固定值判断 -->
    <Footer v-show="!this.$route.meta.isFooterHidden"/>

    <!-- 第二种.封装函数判断路径 -->
    <!-- <Footer v-show="!footerIsHidden"/> -->

    <!-- 第三种.切割path判断路径 -->
    <!-- <Footer v-show="path === 'home' || path === 'search' "/> -->
  </div>
</template>

<script>
import {isFooterHidden} from "@/utils/HiddenFooter"
import { mapActions } from "vuex";

import Header from '@comp/Header'
import Footer from '@comp/Footer'
export default {
  name: 'App',
  components:{
    Header,
    Footer
  },
  methods:{
    //1.映射获取三级列表请求的actions函数
    ...mapActions("home", ["getCateGoryList"]),
  },

  mounted() {
     //1.初始化调用actions函数发送请求
    this.getCateGoryList();
  },

  computed:{
    //1.计算当前路由是不是login或者register 是就返回tuue 就让Footer组件隐藏
    footerIsHidden(){
      return isFooterHidden.call(this , "login") || isFooterHidden.call(this , "register")
    },

    //2.计算当前路由的纯路径
    path(){
      return this.$route.path.split("/")[1]
    }
  },

}
</script>

<style lang = "less" scoped>
</style>